#include "Monster.h"
#include <string.h>

void CMonster::Init(const MONSTER_INFO &info)
{
	m_monsterId = info.idx;
	m_Agent.params.radius = info.radius;
	m_Agent.params.height = info.height;
	m_Agent.params.maxAcceleration = info.maxAcceleration;
	m_Agent.params.maxSpeed = info.maxSpeed;
	m_Agent.params.collisionQueryRange = m_Agent.params.radius * 12.0f;
	m_Agent.params.pathOptimizationRange = m_Agent.params.radius * 30.0f;
	m_Agent.params.updateFlags = info.updateFlags;
	/*m_Agent.params.updateFlags |= DT_CROWD_ANTICIPATE_TURNS;
	m_Agent.params.updateFlags |= DT_CROWD_OPTIMIZE_VIS;
	m_Agent.params.updateFlags |= DT_CROWD_OPTIMIZE_TOPO;
	m_Agent.params.updateFlags |= DT_CROWD_OBSTACLE_AVOIDANCE;*/
	m_Agent.params.obstacleAvoidanceType = (unsigned char)info.obstacleAvoidanceType;
	m_Agent.params.separationWeight = info.separationWeight;
	m_Agent.params.queryFilterType = info.queryFilterType;
	m_modelId = info.modelId;
	m_bObstacle = info.bObstacle;
	m_bCollisions = info.bCollisions;
	m_startPos = info.bornPos;
}

Position3D& CMonster::GetMonsterStart()
{
	return m_startPos;
}

void CMonster::SetMoveTarget(const Position3D& targetPos)
{
	m_targetPos = targetPos;
}

void CMonster::SetCurPos(const Position3D& npos)
{
	m_npos = npos;
}

Position3D CMonster::GetCurPos()
{
	return m_npos;
}

dtCrowdAgentParams* CMonster::GetAgentParam()
{
	return &m_Agent.params;
}

dtCrowdAgent* CMonster::GetAgent()
{
	return &m_Agent;
}

bool CMonster::GetObstacle()
{
	return m_bObstacle;
}

bool CMonster::GetCollisions()
{
	return m_bCollisions;
}

MONSTER_ID CMonster::GetMonsterId()
{
	return m_monsterId;
}

void CMonster::UpdateMonsterParameters(const dtCrowdAgentParams* params)
{
	memcpy(&m_Agent.params, params, sizeof(dtCrowdAgentParams));
}